<template>
  <ConditionBox :margin-bottom="20">
    <template #left>
      <a-space>
        <a-input-search
          :style="{ width: '220px' }"
          placeholder="姓名/工号"
          search-button
          @search="onSearch"
          @press-enter="onSearch"
          v-model="nameSearch"
        />
      </a-space>
    </template>
    <template #right>
      <a-space> </a-space>
    </template>
  </ConditionBox>
  <table-turn :table-data="getTableData" ref="tableRef" :args="args">
    <a-table-column :width="80">
      <template #title> 序号 </template>
      <template #cell="{ rowIndex }">
        {{ rowIndex + 1 }}
      </template>
    </a-table-column>
    <a-table-column
      :width="200"
      align="center"
      data-index="name"
      title="绩效考核名称"
    >
    </a-table-column>
    <a-table-column
      :width="200"
      align="center"
      data-index="definition"
      title="考核对象"
    >
    </a-table-column>
    <a-table-column
      :width="200"
      align="center"
      data-index="definition"
      title="工号"
    >
    </a-table-column>
    <a-table-column
      :width="200"
      align="center"
      data-index="definition"
      title="部门"
    >
    </a-table-column>
    <a-table-column
      :width="200"
      align="center"
      data-index="definition"
      title="职位"
    >
    </a-table-column>
    <a-table-column
      :width="200"
      align="center"
      data-index="definition"
      title="考核类别"
    >
    </a-table-column>
    <a-table-column
      :width="200"
      align="center"
      data-index="definition"
      title="考核周期"
    >
    </a-table-column>
    <a-table-column :width="200" data-index="definition" title="考核到期天数">
    </a-table-column>
    <a-table-column
      :width="120"
      align="center"
      data-index=""
      title="操作"
      fixed="right"
    >
      <template #cell="{ record }">
        <a-tooltip content="处理">
          <IconFont
            type="icon-edit"
            :size="26"
            :style="{
              marginRight: '10px',
              cursor: 'pointer'
            }"
            @click="goEdit(record)"
          />
        </a-tooltip>
        <a-tooltip content="删除" position="left">
          <a-popconfirm content="是否确认删除该条数据?" @ok="del(record.id)">
            <icon-font
              type="icon-delete"
              :size="26"
              :style="{
                cursor: 'pointer',
                marginRight: '10px'
              }"
            />
          </a-popconfirm>
        </a-tooltip>
      </template>
    </a-table-column>
  </table-turn>
</template>

<script setup lang="ts">
import TableTurn, { paramsType } from '@/components/TableTurn/index.vue';
import { getAppealList } from '@/apis/human/base/variationManager/probation';

const props = withDefaults(
  defineProps<{
    appealParams: {
      /**
       * 15待申诉受理 16已申诉受理
       */
      optionStatus: number;
      name?: string;
    };
  }>(),
  {}
);
// 表格配置
const args = reactive({
  rowSelection: {
    type: 'checkbox',
    showCheckedAll: true,
    onlyCurrent: false
  }
});
// 获取表格数据
const getTableData = async (params: paramsType) => {
  try {
    const res = await getAppealList({
      ...params,
      ...props.appealParams
    });
    return Promise.resolve(res);
  } catch (error: unknown) {
    console.log(error);
  }
};
</script>
